package com.yanqu.road.server.manager.rank;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.entity.rank.cross.CrossUserRank;
import com.yanqu.road.entity.union.cross.CrossUnionServerGroup;
import com.yanqu.road.logic.cross.CrossGroupMonthRankListModel;
import com.yanqu.road.server.manger.CrossUnionServerGroupMgr;
import com.yanqu.road.server.manger.IUserBaseInfoSyncListener;
import com.yanqu.road.utils.date.DateHelper;

public class MonthRankUserBaseSyncListener implements IUserBaseInfoSyncListener {

    @Override
    public void notifySync(UserBaseInfo userBaseInfo, long userId) {
        long serverId = userBaseInfo.getServerId();
        CrossUnionServerGroup serverGroup = CrossUnionServerGroupMgr.getServerGroupByServerId(serverId);
        if (null == serverGroup) {
            return;
        }
        if (!CrossGroupUserMonthAbilityRankMgr.isServerGroupOver(serverId)){
            return;
        }
        CrossGroupMonthRankListModel rankListModel = CrossGroupUserMonthAbilityRankMgr.getCrossGroupRankListModelMap(serverGroup.getGroupId(), DateHelper.getMonth(), false);
        if (null == rankListModel) {
            return;
        }

        CrossUserRank crossUserRank = rankListModel.getMyCrossUserRank(userId, serverId);
        if (null == crossUserRank){
            return ;
        }
        crossUserRank.setUserBaseInfo(userBaseInfo);

    }
}
